<!-- 审核通知master views/master/notice.vue -->
<template>
  <tContent :title="title">
    <template slot="otherContent">
      <ul>
        <router-link tag="li" :to="{path:'/taskDetail/'+item.lsStatus+'/'+item.workOrderId}" v-for="item in noticeList" :key="item.lsId">
          <van-row>
            <van-col span="12"><span class="workerName">{{isManager ? item.outworkerName:item.managerName}}</span>[{{isManager ? item.companyName:'经办人'}}]</van-col>
            <van-col class="creatTime" span="12">{{item.lsCreateTime}}</van-col>
          </van-row>
          <van-row>
            <van-col span="24">{{item.customerAddress}}</van-col>
          </van-row>
        </router-link>
      </ul>
    </template>
  </tContent>
</template>
<script>
import tContent from '@/components/templete/content.vue'
import { mapState, mapGetters } from 'vuex'
import {noticeTitle} from '@/utils/tools'
export default {
  data() {
    return {
      title:'通知',
    }
  },
  computed: {
    ...mapState(['masterOrders','workerOrders']),
    ...mapGetters(['role','isManager']),
    noticeList() {
      const lsStatus = this.getLsStatus()
      if(lsStatus === 'expired'){
        // 筛选过期任务
       return this.masterOrders.filter(x =>  this.dayjs().isAfter(this.dayjs(x.workOrderEndDate)))
      }else if(this.isManager){
        return this.masterOrders.filter(x => x.lsStatus === lsStatus)
      }else{
        console.log(this.workerOrders)
        return this.workerOrders
      }
    }
  },
  components: {
    tContent
  },
  methods: {
    getNotice() {
      this.isManager? 
      this.$store.dispatch('getMasterOrders'): this.$store.dispatch('getWorksOrders')
    },
    setTitle(){
     const lsStatus = this.getLsStatus()
      this.title =this.isManager ? noticeTitle(lsStatus) : '任务通知'
    },
    getLsStatus(){
     return this.$route.params.lsStatus
    }
  },
  mounted() {
    this.getNotice()
    this.setTitle()
  }
}
</script>
<style lang="less" scoped>
ul{
  padding: 0 @padding-md;
  margin-top: -80px;
  li{
    background: @gray-1;
    margin-top: @padding-sm;
    padding: @padding-md;
    border-radius: @border-radius-sm;
    font-size: @font-size-sm;
    line-height: 2em;
    .workerName{
      padding-right: @padding-xs;
      color: @black;
      font-size: @font-size-md;
    }
    .creatTime{
      text-align: right;
    }
  }
}
</style>
